package com.beans;

import creator.ui.graphics.Magicanvas;
import creator.ui.graphics.bean.Bean;
import java.awt.Image;
import java.awt.Rectangle;
import java.io.PrintStream;
import java.util.ArrayList;

public class BirdBean extends Bean {

  private ArrayList<Image> blue;
  private ArrayList<Image> red;
  private ArrayList<Image> yellow;
  private static int birdX;
  private static int birdGameX;
  private static int birdY;
  private static int birdW;
  private static int birdH;
  private static boolean isAlive = true;
  private static Rectangle birdR;
  private static int r = 0;

  public void initBean(Magicanvas cvs) {
    r = 0;

    this.blue =
      getGroupOfImages(
        new String[] {
          "/res/img/birds/bb1.gif",
          "/res/img/birds/bb2.gif",
          "/res/img/birds/bb3.gif",
        }
      );

    this.red =
      getGroupOfImages(
        new String[] {
          "/res/img/birds/rb1.gif",
          "/res/img/birds/rb2.gif",
          "/res/img/birds/rb3.gif",
        }
      );

    this.yellow =
      getGroupOfImages(
        new String[] {
          "/res/img/birds/yb1.gif",
          "/res/img/birds/yb2.gif",
          "/res/img/birds/yb3.gif",
        }
      );

    trackerImages(this.blue, cvs);
    trackerImages(this.red, cvs);
    trackerImages(this.yellow, cvs);
    birdW = ((Image) this.blue.get(1)).getWidth(cvs);
    birdH = ((Image) this.blue.get(1)).getHeight(cvs);
    birdY = (int) (307.0D - birdH * 2.2D);
    birdX = 172 - birdW / 2;
    birdGameX = 86;

    birdR = new Rectangle(birdGameX, birdY, birdW, birdH);
  }

  public ArrayList<Image> getBird() {
    int i = (int) (Math.random() * 3.0D);
    if (i == 0) return this.blue;
    if (i == 1) return this.red;
    if (i == 2) return this.yellow;

    System.out.println(i);
    return null;
  }

  public static int getBirdX() {
    return birdX;
  }

  public static int getBirdGameX() {
    return birdGameX;
  }

  public static int getBirdY() {
    return birdY;
  }

  public static void setBirdY(int Y) {
    birdY = Y;
    birdR.setBounds(birdGameX, birdY, birdW, birdH);
  }

  public static int getBirdW() {
    return birdW;
  }

  public static int getBirdH() {
    return birdH;
  }

  public static int getR() {
    return r;
  }

  public static void setR(int r) {
    r = r;
  }

  public static boolean _isAlive() {
    return isAlive;
  }

  public static void _setAlive(boolean isAlive) {
    isAlive = isAlive;
  }

  public static Rectangle getBirdR() {
    return birdR;
  }
}
